home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / applescriptMode.tcl < prev    next >
Encoding:
Text File  |  2000-12-06  |  2.7 KB  |  75 lines

  1. #############################################################################
  2. # AppleScript.tcl
  3. #  John Sarapata
  4. #  sarapata_john@jpmorgan.com
  5. #
  6. # Description:
  7. #    This file implements an AppleScript mode, for people who wish Script
  8. #    Editor had complex functions like search and replace. Currently, it
  9. #    only supports color editing and function finding, but I may extend it.
  10. #
  11. #    I have not found a way to distinguish function definitions from
  12. #    on error constructs, so I assume that any "on name" statements at
  13. #    the beginning of the line are definitions. Script Editor saves files
  14. #    in this format, so you will only need to be careful when creating
  15. #    functions in Alpha.
  16. #############################################################################
  17.  
  18. alpha::mode Scrp 1.0.1 dummyScrp {*.script} {electricBraces electricTab} {
  19. } help {
  20.     AppleScript Mode provides keyword coloring and function marking
  21.     with the Marks Menu.
  22. }
  23.  
  24. #===============================================================================
  25. #    Set up the mode variables
  26. newPref    v wordWrap {0} Scrp
  27. newPref    f autoMark {0} Scrp
  28. newPref    v prefixString {--} Scrp
  29. newPref    v leftFillColumn {3} Scrp
  30. newPref    v funcExpr {^(on)[ \t]+(\w+)} Scrp
  31. newPref    v parseExpr {^[^ \t]+[ \t]+(\w+)} Scrp
  32. newPref    v wordBreak {\w+} Scrp
  33. newPref    v wordBreakPreface {\W} Scrp
  34.  
  35. proc dummyScrp {} {}
  36.  
  37. #===============================================================================
  38. #    Set up comments and keywords
  39. set scriptKeyWords {
  40.     on end error global local return it me pi result space tab close copy 
  41.     count data size delete duplicate exists get launch make move open print 
  42.     quit run save in of is after before div mod and not or start starts 
  43.     begin begins end ends contains does equal equals greater less than as 
  44.     reference set try tell if repeat else then times while until with by 
  45.     considering ignoring timeout transaction script property prop first 
  46.     second third fourth fifth sixth seventh eighth ninth tenth last front 
  47.     back middle every some from to through thru
  48. }
  49.  
  50. regModeKeywords -e {--} -b {\(*} {*\)} -c red -k blue Scrp $scriptKeyWords
  51.  
  52. unset scriptKeyWords
  53.  
  54. #===============================================================================
  55. #    File Marking
  56. proc Scrp::MarkFile {} {
  57.     global ScrpmodeVars
  58.     set pos [minPos]
  59.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $ScrpmodeVars(funcExpr) $pos} res]} {
  60.     set start [lindex $res 0]
  61.     set end [lindex $res 1]
  62.     set text [lindex [split [getText $start $end]] 1]
  63.     set pos $end
  64.     set inds($text) $res
  65.     }
  66.     
  67.     if {[info exists inds]} {
  68.     foreach f [lsort [array names inds]] {
  69.         setNamedMark $f [lineStart [pos::math [lineStart [lindex $inds($f) 0]] - 1]] \
  70.           [lindex $inds($f) 0] [lindex $inds($f) 1]
  71.     }
  72.     }
  73. }
  74.  
  75.